package com.example.design.ordermanagement.command.receiver;

import com.example.design.pojo.Order;
import org.springframework.stereotype.Component;

//命令模式接收者
@Component
public class OrderCommandReceiver {
    public void action(Order order){
        switch (order.getOrderState()){
            case ORDER_WAIT_PAY:
                System.out.println("订单号："+order.getOrderId()+"，状态："+order.getOrderState()+"，执行支付");
                System.out.println("存入 DB！");
                return;
            case ORDER_WAIT_SEND:
                System.out.println("订单号："+order.getOrderId()+"，状态："+order.getOrderState()+"，执行发货");
                System.out.println("存入 DB！");
                System.out.println("通过queue通知财务部门");
                System.out.println("通过queue通知物流部门");
                return;
            case ORDER_WAIT_RECEIVE:
                System.out.println("订单号："+order.getOrderId()+"，状态："+order.getOrderState()+"，执行收货");
                System.out.println("存入 DB！");
                return;
            case ORDER_FINISH:
                System.out.println("订单号："+order.getOrderId()+"，状态："+order.getOrderState()+"，执行完成");
                System.out.println("存入 DB！");
                return;
            default:
                throw new UnsupportedOperationException("不支持该状态");
        }
    }
}
